<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        //用法一：删除
        var arr = [2, 3, 4, 5];
        arr.splice(2, 1);//把4删除
        console.log(arr);

        //用法二：插入
        var arr2 = [2,3,4,5];
        arr2.splice(2,0,10);
        console.log(arr2);//2,3,10,4,5

        var arr3 = [2,3,4,5];
        arr3.splice(2,0,10,11,12);
        console.log(arr3);//2,3,10,11,12,4,5


        //用法三：替换
        var arr4 = [2,3,4,5];
        arr4.splice(2,1,10);
        console.log(arr4);//2,3,10,5
    </script>
</body>
</html>